package Polymorphic.PolymorphDemo002;

/**
 * ClassName:Text
 * Package:Polymorphic.PolymorphDemo002
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/1/24-10:49
 * @Version:v1.0
 */
public class Text {
    public static void main(String[] args) {
        Student s = new Student();
        s.setName("张三");
        s.setAge(20);

        Teacher t = new Teacher();
        t.setName("王五");
        t.setAge(35);

        Administrator admin = new Administrator();
        admin.setName("建国");
        admin.setAge(45);

        register(s);
        register(t);
        register(admin);

    }
    //这个方法既能接受老师,又能接受学生,还能接收管理员
    //只能把参数写成这三个类型的父类
    public static void register(Person p){
        p.show();
    }
}
